package com.wyl.sso.util;

import java.security.MessageDigest;

/**
 * @Auther: wyl
 * @Date: 2021/7/5
 * @Description:
 */
public class CommonUtil {

    /**
     * MD5加密
     *
     * @param data
     * @return
     */
    public static String getMD5Str(String data) {
        try {
            java.security.MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] array = md.digest(data.getBytes("UTF-8"));
            StringBuilder sb = new StringBuilder();
            for (byte item : array) {
                sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
            }

            return sb.toString().toUpperCase();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return null;
    }
}
